<?php
// Displays the colors of the product
function displayColors($colors) {
    $output = "";
    foreach($colors as $i=>$color) $output.= ($i>0?', ':'').CHtml::encode($color->name).CHtml::encode($color->hex);

    return $output;
}

// Displays the networks of the product
function displayNetworks($networks) {
    $output = "";
    foreach($networks as $i=>$network) $output.= ($i>0?', ':'').CHtml::encode($network->name);

    return $output;
}

// Displays the Input/Output of the product
function displayIos($ios) {
    $output = "";
    foreach($ios as $i=>$io) $output.= ($i>0?', ':'').CHtml::encode($io->name);

    return $output;
}

// Displays the languages of the product
function displayLanguages($languages) {
    $output = "";
    foreach($languages as $i=>$language) $output.= ($i>0?', ':'').CHtml::encode($language->name);

    return $output;
}

$this->breadcrumbs=array(
	'Products'=>array('index'),
	$model->name,
);

$this->menu=array(
	array('label'=>'List Product', 'url'=>array('index')),
	array('label'=>'Create Product', 'url'=>array('create')),
	array('label'=>'Update Product', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Delete Product', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'Manage Product', 'url'=>array('admin')),
);
?>

<h1>View Product #<?php echo $model->id; ?></h1>

<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		'id',
		'category_id',
		'os_id',
		'name',
		'model',
        array(               // related colors
            'label'=>$model->getAttributeLabel('colors'),
            'type'=>'raw',
            'value'=>displayColors($model->colors),
        ),
		'chip',
		'size',
		'weight',
		'display',
		'storage',
		'memory',
		'sensors',
		array(               // related networks
            'label'=>$model->getAttributeLabel('networks'),
            'type'=>'raw',
            'value'=>displayNetworks($model->networks),
        ),
		'camera',
		'battery',
		'power',
		'audio',
		'video',
        array(               // related ios
            'label'=>$model->getAttributeLabel('ios'),
            'type'=>'raw',
            'value'=>displayNetworks($model->ios),
        ),
        array(               // related languages
            'label'=>$model->getAttributeLabel('languages'),
            'type'=>'raw',
            'value'=>displayNetworks($model->languages),
        ),
		'extra',
		'picture',
		'details',
	),
)); ?>
